package cn.itcast.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @Author: 斌
 * @DateTime: 2023年03月29日  23:34:09
 * @Description: cn.itcast.web
 * @Version: 1.0
 */
@RestController
public class UserController {

    @Autowired
    private RedisTemplate redisTemplate;

    @Value("${spring.dateformat}")
    private String dateformat;
    @RequestMapping("/hello")
    public String hello(){
        redisTemplate.opsForValue().set("username","zhangsan");
        redisTemplate.opsForValue().get("username");
        String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern(dateformat));
        return format;
    }
}
